package com.ocom.xcxapi.controller;

import com.alibaba.fastjson.JSON;
import com.ocom.common.constant.CompanyServiceUrl;
import com.ocom.common.entity.master.EntityWechatPerInfo;
import com.ocom.common.enums.ResultEnum;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.security.utils.SecurityUtils;
import com.ocom.xcxapi.client.HumanClientService;
import com.ocom.xcxapi.service.CompanyService;
import com.ocom.xcxapi.vo.RegisterCodeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@PreAuthorize("hasRole('ROLE_XCX')")
@RestController
public class RegCodeController {


    @Autowired
    private CompanyService companyService;



    /**
     * 2.6.注册码绑定(user/registerCode)
     * */
    @PostMapping(CompanyServiceUrl.URL_UserRegisterCode)
    public Result UserRegisterCode(@Validated @RequestBody RegisterCodeVo registerCodeVo){
        if (registerCodeVo.getRegCode() == null || registerCodeVo.getComId() ==null || registerCodeVo.getOpenid() == null){
            return ResultUtil.error(ResultEnum.Err_203);
        }

        return companyService.UserRegisterCode(registerCodeVo);
    }
}
